﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="baseUrl" value="${pageContext.request.contextPath }"></c:set>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="utf-8" />
<title>Insert title here</title>
<link type="text/css" rel="stylesheet" href="${baseUrl }/css/style.css">
<script type="text/javascript">
function doDel(id) {
	var flag = confirm("确认删除？");
	if(flag){
		window.location="${baseUrl }/ProviderController/deleteProvider?id="+id
	}
}
</script>
</script>
</head>
<body>
	<div class="menu">

		<table>
			<tbody>
				<tr>
					<td><form>
						供应商名称：<input name="providerName" 
						class="input-text" type="text" value="${providerName }">
							&nbsp;&nbsp;
						供应商描述：<input name="providerDesc"
								class="input-text" type="text" value="${providerDesc }">
								&nbsp;&nbsp;
								<input value="组 合 查 询" type="submit">
						</form>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
	<div class="main">
		<div class="optitle clearfix">
		<c:if test="${user1.supers eq 1 }">
				<em>
				<input value="添加数据" class="input-button" onclick="window.location='${baseUrl }/providerAdd.jsp'" type="button">
				</em>
		</c:if>
			<div class="title">供应商管理&gt;&gt;</div>
		</div>

		<div class="content">
			<table class="list">
				<tbody>
					<tr>
						<td><div class="STYLE1" align="center">序号</div></td>
						<td><div class="STYLE1" align="center">编号</div></td>
						<td><div class="STYLE1" align="center">供应商名称</div></td>
						<td><div class="STYLE1" align="center">供应商描述</div></td>
						<td><div class="STYLE1" align="center">联系人</div></td>

						<td><div class="STYLE1" align="center">电话</div></td>
						<td><div class="STYLE1" align="center">地址</div></td>
						<td><div class="STYLE1" align="center">传真</div></td>
						<c:if test="${user1.supers eq 1 }">
						<td><div class="STYLE1" align="center">操作</div></td>
						</c:if>
					</tr>
					
				<c:forEach items="${list }" var="provider">
					<tr>
						<c:set value="${i+1 }" var="i"></c:set>
						<td><div class="STYLE1" align="center">${i}</div></td>
						<td><div class="STYLE1" align="center">${provider.id }</div></td>
						<td><div class="STYLE1" align="center">${provider.name }</div></td>
						<td><div class="STYLE1" align="center">${provider.desc }</div></td>
						<td><div class="STYLE1" align="center">${provider.contact }</div></td>
						<td><div class="STYLE1" align="center">${provider.phone }</div></td>
						<td><div class="STYLE1" align="center">${provider.address }</div></td>
						<td><div class="STYLE1" align="center">${provider.fax }</div></td>
						<c:if test="${user1.supers eq 1 }">
						<td><a href="javascript:doDel(${provider.id })">删除</a>
					&nbsp;&nbsp;<a href="${baseUrl }/ProviderController/getProvider?id=${provider.id}">更新</a>
					</td></c:if>
					</tr>	
				</c:forEach>
					
				</tbody>
			</table>
		</div>
	</div>
	
	<c:url value="ProviderController/getAllProvider" var="first">
		<c:param name="pageIndex" value="1"></c:param>
		<c:param name="providerName" value="${providerName }"></c:param>
		<c:param name="providerDesc" value="${providerDesc }"></c:param>
	</c:url>
	<c:url value="ProviderController/getAllProvider" var="forward">
		<c:param name="pageIndex" value="${pageIndex-1 }"></c:param>
		<c:param name="providerName" value="${providerName }"></c:param>
		<c:param name="providerDesc" value="${providerDesc }"></c:param>
	</c:url>
	<c:url value="ProviderController/getAllProvider" var="next">
		<c:param name="pageIndex" value="${pageIndex+1 }"></c:param>
		<c:param name="providerName" value="${providerName }"></c:param>
		<c:param name="providerDesc" value="${providerDesc }"></c:param>
	</c:url>
	<c:url value="ProviderController/getAllProvider" var="last">
		<c:param name="pageIndex" value="${totalPage }"></c:param>
		<c:param name="providerName" value="${providerName }"></c:param>
		<c:param name="providerDesc" value="${providerDesc }"></c:param>
	</c:url>
	<font size="4" color="blue">
		<a href="${baseUrl }/${first }">首页</a>
	<!-- 当前页码等于1时隐藏"上一页" -->
	<c:if test="${pageIndex > 1 }">
		<a href="${baseUrl }/${forward }">上一页</a>
	</c:if>
	<!-- 当前页码为总页码时，隐藏"下一页" -->
	<c:if test="${pageIndex < totalPage }">
		<a href="${baseUrl }/${next }">下一页</a>
	</c:if>
		<a href="${baseUrl }/${last }">尾页</a>
		总共有${totalPage }页
		&nbsp;
		总共有<font color="red">${totalCount }</font>条数据，共<font color="red">${totalPage }</font>页
		</font>
</body>
</html>